#ifndef STOREIOMANAGER_H
#define STOREIOMANAGER_H

#include <QMainWindow>
#include <QMessageBox>
#include <QPushButton>
#include <QMouseEvent>

#include "User.h"
#include "DatabaseManager.h"

namespace Ui {
class StoreIOManager;
}

class StoreIOManager : public QMainWindow
{
    Q_OBJECT

public:
    explicit StoreIOManager(QWidget *parent = nullptr);
    explicit StoreIOManager(const User& userInfo, QWidget *parent = nullptr);
    ~StoreIOManager();

    void initMenu();
    void initIOManagePageMenu();
    void initRecordManagePageMenu();
protected:
    void mouseReleaseEvent(QMouseEvent *event) override;

private slots:
    void m_on_IOManage_tv_partInfoList_clicked(const QModelIndex& index);
    void m_on_IOManage_btn_refresh_clicked();
    void m_on_IOManage_btn_yes_clicked();

    void m_on_record_btn_refresh_clicked();
private:
    Ui::StoreIOManager *ui;

    DatabaseManager* m_DBManager;

    User m_operatorUserInfo;

    QSqlQueryModel* m_partInfoSqlQueryModel;
    QSqlQueryModel* m_outRecordInfoSqlQueryModel;
    QSqlQueryModel* m_inRecordInfoSqlQueryModel;

    bool m_selectPartInfoFlag;
    Part m_currentPartInfo;
};

class StoreIORecordManagerSqlQueryModel:public QSqlQueryModel
{
public:
    StoreIORecordManagerSqlQueryModel(QObject* parent = nullptr);
    QVariant data(const QModelIndex& index,int role = Qt::DisplayRole)const override;
};

#endif // STOREIOMANAGER_H
